2 Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
\r
3 Website: http://purebeam.biz
\r
4 E-mail : purebeam@gmail.com
\r
6 #property copyright "http://BigGame24.tripod.com/, NIKRA EA, 2010"
\r
11 double g_pips_88 = 10.0;
\r
12 double g_pips_96 = 50.0;
\r
13 double gd_104 = 10.0;
\r
14 double gd_112 = 10.0;
\r
15 extern double Lots = 0.01;
\r
16 double gd_128 = 1.0;
\r
17 double gd_136 = 0.0;
\r
18 extern bool UseHourTrade = FALSE;
\r
19 extern int FromHourTrade = 6;
\r
20 extern int ToHourTrade = 18;
\r
21 double g_slippage_156 = 3.0;
\r
22 double g_pips_164 = 20.0;
\r
24 bool gi_176 = FALSE;
\r
25 double gd_180 = 20.0;
\r
26 bool gi_188 = FALSE;
\r
27 bool gi_192 = FALSE;
\r
28 double gd_196 = 48.0;
\r
29 extern int MagicNumber = 20000;
\r
32 double gd_unused_224;
\r
33 double gd_unused_232;
\r
41 string gs_300 = "NIKRA EA";
\r
48 double gd_336 = 0.0;
\r
49 bool gi_344 = FALSE;
\r
50 bool gi_348 = FALSE;
\r
51 bool gi_352 = FALSE;
\r
53 bool gi_360 = FALSE;
\r
54 int g_datetime_364 = 0;
\r
55 int g_datetime_368 = 0;
\r
60 gd_288 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
\r
69 Comment("BigGame24.tripod.com"
\r
71 + "________________________________"
\r
75 + "________________________________"
\r
77 + "Broker: " + AccountCompany()
\r
79 + "Time Local: " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS)
\r
81 + "________________________________"
\r
83 + "Name: " + AccountName()
\r
85 + "Account Number: " + AccountNumber()
\r
87 + "Account Currency: " + AccountCurrency()
\r
89 + "Account Leverage: " + DoubleToStr(AccountLeverage(), 0)
\r
91 + "________________________________"
\r
93 + "ALL ORDERS: " + OrdersTotal()
\r
95 + "________________________________"
\r
97 + "Account BALANCE: " + DoubleToStr(AccountBalance(), 2)
\r
99 + "Account EQUITY: " + DoubleToStr(AccountEquity(), 2)
\r
101 + "Used MARGIN: " + DoubleToStr(AccountMargin(), 2)
\r
103 + "________________________________"
\r
105 + "BigGame24.tripod.com");
\r
106 double l_ord_lots_20;
\r
107 double l_ord_lots_28;
\r
108 double l_iclose_36;
\r
109 double l_iclose_44;
\r
110 string ls_0 = "2019.07.07";
\r
111 int l_str2time_8 = StrToTime(ls_0);
\r
112 if (TimeCurrent() >= l_str2time_8) {
\r
113 Alert("http://BigGame24.tripod.com/");
\r
116 if (UseHourTrade) {
\r
117 if (!(Hour() >= FromHourTrade && Hour() <= ToHourTrade)) {
\r
118 Comment("This is not trading time.");
\r
122 if (gi_188) TrailingAlls(gd_104, gd_112, g_price_240);
\r
124 if (TimeCurrent() >= gi_312) {
\r
125 CloseThisSymbolAll();
\r
126 Print("Closed All due to TimeOut");
\r
129 if (g_time_308 == Time[0]) return (0);
\r
130 g_time_308 = Time[0];
\r
131 double ld_12 = CalculateProfit();
\r
133 if (ld_12 < 0.0 && MathAbs(ld_12) > gd_180 / 100.0 * AccountEquityHigh()) {
\r
134 CloseThisSymbolAll();
\r
135 Print("Closed All due to Stop Out");
\r
139 gi_332 = CountTrades();
\r
140 if (gi_332 == 0) gi_296 = FALSE;
\r
141 for (g_pos_328 = OrdersTotal() - 1; g_pos_328 >= 0; g_pos_328--) {
\r
142 OrderSelect(g_pos_328, SELECT_BY_POS, MODE_TRADES);
\r
143 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
144 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
145 if (OrderType() == OP_BUY) {
\r
148 l_ord_lots_20 = OrderLots();
\r
152 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
153 if (OrderType() == OP_SELL) {
\r
156 l_ord_lots_28 = OrderLots();
\r
161 if (gi_332 > 0 && gi_332 <= gi_172) {
\r
163 gd_264 = FindLastBuyPrice();
\r
164 gd_272 = FindLastSellPrice();
\r
165 if (gi_348 && gd_264 - Ask >= g_pips_164 * Point) gi_344 = TRUE;
\r
166 if (gi_352 && Bid - gd_272 >= g_pips_164 * Point) gi_344 = TRUE;
\r
172 gd_216 = AccountEquity();
\r
175 gd_264 = FindLastBuyPrice();
\r
176 gd_272 = FindLastSellPrice();
\r
179 fOrderCloseMarket(0, 1);
\r
180 gd_320 = NormalizeDouble(gd_136 * l_ord_lots_28, gd_128);
\r
181 } else gd_320 = fGetLots(OP_SELL);
\r
184 if (gd_320 > 0.0) {
\r
186 gi_356 = OpenPendingOrder(1, gd_320, Bid, g_slippage_156, Ask, 0, 0, gs_300 + "-" + gi_316, MagicNumber, 0, HotPink);
\r
188 Print("Error: ", GetLastError());
\r
191 gd_272 = FindLastSellPrice();
\r
199 fOrderCloseMarket(1, 0);
\r
200 gd_320 = NormalizeDouble(gd_136 * l_ord_lots_20, gd_128);
\r
201 } else gd_320 = fGetLots(OP_BUY);
\r
204 if (gd_320 > 0.0) {
\r
205 gi_356 = OpenPendingOrder(0, gd_320, Ask, g_slippage_156, Bid, 0, 0, gs_300 + "-" + gi_316, MagicNumber, 0, Lime);
\r
207 Print("Error: ", GetLastError());
\r
210 gd_264 = FindLastBuyPrice();
\r
218 if (gi_344 && gi_332 < 1) {
\r
219 l_iclose_36 = iClose(Symbol(), 0, 2);
\r
220 l_iclose_44 = iClose(Symbol(), 0, 1);
\r
223 if (!gi_352 && !gi_348) {
\r
225 if (l_iclose_36 > l_iclose_44) {
\r
226 gd_320 = fGetLots(OP_SELL);
\r
227 if (gd_320 > 0.0) {
\r
228 gi_356 = OpenPendingOrder(1, gd_320, g_bid_248, g_slippage_156, g_bid_248, 0, 0, gs_300 + "-" + gi_316, MagicNumber, 0, HotPink);
\r
230 Print(gd_320, "Error: ", GetLastError());
\r
233 gd_264 = FindLastBuyPrice();
\r
237 gd_320 = fGetLots(OP_BUY);
\r
238 if (gd_320 > 0.0) {
\r
239 gi_356 = OpenPendingOrder(0, gd_320, g_ask_256, g_slippage_156, g_ask_256, 0, 0, gs_300 + "-" + gi_316, MagicNumber, 0, Lime);
\r
241 Print(gd_320, "Error: ", GetLastError());
\r
244 gd_272 = FindLastSellPrice();
\r
249 if (gi_356 > 0) gi_312 = TimeCurrent() + 60.0 * (60.0 * gd_196);
\r
252 gi_332 = CountTrades();
\r
255 for (g_pos_328 = OrdersTotal() - 1; g_pos_328 >= 0; g_pos_328--) {
\r
256 OrderSelect(g_pos_328, SELECT_BY_POS, MODE_TRADES);
\r
257 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
258 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
259 if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
\r
260 g_price_240 += OrderOpenPrice() * OrderLots();
\r
261 ld_52 += OrderLots();
\r
265 if (gi_332 > 0) g_price_240 = NormalizeDouble(g_price_240 / ld_52, Digits);
\r
267 for (g_pos_328 = OrdersTotal() - 1; g_pos_328 >= 0; g_pos_328--) {
\r
268 OrderSelect(g_pos_328, SELECT_BY_POS, MODE_TRADES);
\r
269 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
270 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
271 if (OrderType() == OP_BUY) {
\r
272 g_price_208 = g_price_240 + g_pips_88 * Point;
\r
273 gd_unused_224 = g_price_208;
\r
274 gd_336 = g_price_240 - g_pips_96 * Point;
\r
278 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
279 if (OrderType() == OP_SELL) {
\r
280 g_price_208 = g_price_240 - g_pips_88 * Point;
\r
281 gd_unused_232 = g_price_208;
\r
282 gd_336 = g_price_240 + g_pips_96 * Point;
\r
289 if (gi_296 == TRUE) {
\r
290 for (g_pos_328 = OrdersTotal() - 1; g_pos_328 >= 0; g_pos_328--) {
\r
291 OrderSelect(g_pos_328, SELECT_BY_POS, MODE_TRADES);
\r
292 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
293 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) OrderModify(OrderTicket(), g_price_240, OrderStopLoss(), g_price_208, 0, Yellow);
\r
301 double ND(double ad_0) {
\r
302 return (NormalizeDouble(ad_0, Digits));
\r
305 int fOrderCloseMarket(bool ai_0 = TRUE, bool ai_4 = TRUE) {
\r
307 for (int l_pos_12 = OrdersTotal() - 1; l_pos_12 >= 0; l_pos_12--) {
\r
308 if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) {
\r
309 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
310 if (OrderType() == OP_BUY && ai_0) {
\r
312 if (!IsTradeContextBusy()) {
\r
313 if (!OrderClose(OrderTicket(), OrderLots(), ND(Bid), 5, CLR_NONE)) {
\r
314 Print("Error close BUY " + OrderTicket());
\r
318 if (g_datetime_364 != iTime(NULL, 0, 0)) {
\r
319 g_datetime_364 = iTime(NULL, 0, 0);
\r
320 Print("Need close BUY " + OrderTicket() + ". Trade Context Busy");
\r
325 if (OrderType() == OP_SELL && ai_4) {
\r
327 if (!IsTradeContextBusy()) {
\r
328 if (!OrderClose(OrderTicket(), OrderLots(), ND(Ask), 5, CLR_NONE)) {
\r
329 Print("Error close SELL " + OrderTicket());
\r
333 if (g_datetime_368 != iTime(NULL, 0, 0)) {
\r
334 g_datetime_368 = iTime(NULL, 0, 0);
\r
335 Print("Need close SELL " + OrderTicket() + ". Trade Context Busy");
\r
346 double fGetLots(int a_cmd_0) {
\r
354 l_lots_4 = NormalizeDouble(Lots * MathPow(gd_136, gi_316), gd_128);
\r
359 for (int l_pos_20 = OrdersHistoryTotal() - 1; l_pos_20 >= 0; l_pos_20--) {
\r
360 if (OrderSelect(l_pos_20, SELECT_BY_POS, MODE_HISTORY)) {
\r
361 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
362 if (l_datetime_16 < OrderCloseTime()) {
\r
363 l_datetime_16 = OrderCloseTime();
\r
364 if (OrderProfit() < 0.0) l_lots_4 = NormalizeDouble(OrderLots() * gd_136, gd_128);
\r
365 else l_lots_4 = Lots;
\r
368 } else return (-3);
\r
371 if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= 0.0) return (-1);
\r
372 if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
\r
376 int CountTrades() {
\r
378 for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
\r
379 OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
\r
380 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
381 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
\r
382 if (OrderType() == OP_SELL || OrderType() == OP_BUY) l_count_0++;
\r
384 return (l_count_0);
\r
387 void CloseThisSymbolAll() {
\r
388 for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
\r
389 OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
\r
390 if (OrderSymbol() == Symbol()) {
\r
391 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
\r
392 if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_156, Blue);
\r
393 if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_156, Red);
\r
400 int OpenPendingOrder(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) {
\r
401 int l_ticket_60 = 0;
\r
402 int l_error_64 = 0;
\r
403 int l_count_68 = 0;
\r
407 for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
\r
408 l_ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
\r
409 l_error_64 = GetLastError();
\r
410 if (l_error_64 == 0/* NO_ERROR */) break;
\r
411 if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break;
\r
416 for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
\r
417 l_ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
\r
418 l_error_64 = GetLastError();
\r
419 if (l_error_64 == 0/* NO_ERROR */) break;
\r
420 if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break;
\r
425 for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
\r
427 l_ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, ai_32), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
\r
428 l_error_64 = GetLastError();
\r
429 if (l_error_64 == 0/* NO_ERROR */) break;
\r
430 if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break;
\r
435 for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
\r
436 l_ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
\r
437 l_error_64 = GetLastError();
\r
438 if (l_error_64 == 0/* NO_ERROR */) break;
\r
439 if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break;
\r
444 for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
\r
445 l_ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
\r
446 l_error_64 = GetLastError();
\r
447 if (l_error_64 == 0/* NO_ERROR */) break;
\r
448 if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break;
\r
453 for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
\r
454 l_ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, ai_32), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
\r
455 l_error_64 = GetLastError();
\r
456 if (l_error_64 == 0/* NO_ERROR */) break;
\r
457 if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break;
\r
461 return (l_ticket_60);
\r
464 double StopLong(double ad_0, int ai_8) {
\r
465 if (ai_8 == 0) return (0);
\r
466 return (ad_0 - ai_8 * Point);
\r
469 double StopShort(double ad_0, int ai_8) {
\r
470 if (ai_8 == 0) return (0);
\r
471 return (ad_0 + ai_8 * Point);
\r
474 double TakeLong(double ad_0, int ai_8) {
\r
475 if (ai_8 == 0) return (0);
\r
476 return (ad_0 + ai_8 * Point);
\r
479 double TakeShort(double ad_0, int ai_8) {
\r
480 if (ai_8 == 0) return (0);
\r
481 return (ad_0 - ai_8 * Point);
\r
484 double CalculateProfit() {
\r
485 double ld_ret_0 = 0;
\r
486 for (g_pos_328 = OrdersTotal() - 1; g_pos_328 >= 0; g_pos_328--) {
\r
487 OrderSelect(g_pos_328, SELECT_BY_POS, MODE_TRADES);
\r
488 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
489 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
\r
490 if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
\r
495 void TrailingAlls(int ai_0, int ai_4, double a_price_8) {
\r
497 double l_ord_stoploss_20;
\r
500 for (int l_pos_36 = OrdersTotal() - 1; l_pos_36 >= 0; l_pos_36--) {
\r
501 if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) {
\r
502 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
503 if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber) {
\r
504 if (OrderType() == OP_BUY) {
\r
505 li_16 = NormalizeDouble((Bid - a_price_8) / Point, 0);
\r
506 if (li_16 < ai_0) continue;
\r
507 l_ord_stoploss_20 = OrderStopLoss();
\r
508 l_price_28 = Bid - ai_4 * Point;
\r
509 if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 > l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Aqua);
\r
511 if (OrderType() == OP_SELL) {
\r
512 li_16 = NormalizeDouble((a_price_8 - Ask) / Point, 0);
\r
513 if (li_16 < ai_0) continue;
\r
514 l_ord_stoploss_20 = OrderStopLoss();
\r
515 l_price_28 = Ask + ai_4 * Point;
\r
516 if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 < l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Red);
\r
525 double AccountEquityHigh() {
\r
526 if (CountTrades() == 0) gd_372 = AccountEquity();
\r
527 if (gd_372 < gd_380) gd_372 = gd_380;
\r
528 else gd_372 = AccountEquity();
\r
529 gd_380 = AccountEquity();
\r
533 double FindLastBuyPrice() {
\r
534 double l_ord_open_price_8;
\r
536 double ld_unused_0 = 0;
\r
537 int l_ticket_20 = 0;
\r
538 for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) {
\r
539 OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
\r
540 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
541 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) {
\r
542 l_ticket_24 = OrderTicket();
\r
543 if (l_ticket_24 > l_ticket_20) {
\r
544 l_ord_open_price_8 = OrderOpenPrice();
\r
545 ld_unused_0 = l_ord_open_price_8;
\r
546 l_ticket_20 = l_ticket_24;
\r
550 return (l_ord_open_price_8);
\r
553 double FindLastSellPrice() {
\r
554 double l_ord_open_price_8;
\r
556 double ld_unused_0 = 0;
\r
557 int l_ticket_20 = 0;
\r
558 for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) {
\r
559 OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
\r
560 if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
\r
561 if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
\r
562 l_ticket_24 = OrderTicket();
\r
563 if (l_ticket_24 > l_ticket_20) {
\r
564 l_ord_open_price_8 = OrderOpenPrice();
\r
565 ld_unused_0 = l_ord_open_price_8;
\r
566 l_ticket_20 = l_ticket_24;
\r
570 return (l_ord_open_price_8);
\r